using DC2010.Objects.Base;
using DC2010.Objects.Data;

namespace DC2010.Effects
{

/// Effect description
/// ------------------
/// This is standart effect used by torches and any other light which fades with time. Check is set to one second so
/// is we want decrease rate then we have to modify CheckPumpCondition
/// 
/// Param1 - Current charges
/// Param2 - Max charges
/// Param3 - UNUSED
/// Param4 - UNUSED
/// Param5 -  UNUSED
/// sParam1 - Direction. Values are: "+", "-".
/// sParam1 - UNUSED

    public class P_Light_Effect : EffectLogic
    {
        public int counter;
        public string LightAmount { get; set; }
        public string Direction { get; set; }
        
        public P_Light_Effect(EffectData ed): base(ed)
        {
            ShortName = "LIGHT EFFECT";
            LongName = "...";
            Id = "I_EAT_EFFECT";
            EffectType = EffectType.Instant;

            //ed.Charges.Current = Data.Params.Find(A => A.Key == "CHARGES_CURRENT").Value.ToInt();
            //ed.Charges.Max = Data.Params.Find(A => A.Key == "CHARGES_MAX").Value.ToInt();
            LightAmount = Data.Params.Find(A => A.Key == "AMOUNT").Value;
            Direction = Data.Params.Find(A => A.Key == "DIRECTION").Value;
        }

        public override bool CheckPumpCondition(BaseObject aTarget)
        {
            //is enabled, then every 4 seconds
            bool bResult = (base.CheckPumpCondition(aTarget) && (counter % 4) == 0);
            counter++;

            return bResult;
        }

        public override void Pump(BaseObject aTarget)
        {
            if (CheckPumpCondition(aTarget))
            {
                if (Info.ChargesCurrent != 0)
                {             
                   if (Direction == "-")
                   {
                       LightAmount += 0 - Info.ChargesCurrent;
                   }
                   else
                   {
                       LightAmount += Info.ChargesCurrent;
                   }

                   Info.ChargesCurrent--;
                    
                   //Root.I.GameSystem.Light.AddLightEffect(this, this.Info.Id);   
                }                   
             
            }
        }
    }
}
